package cn.edu.scau.service.impl;

import cn.edu.scau.dao.MedicationrecordMapper;
import cn.edu.scau.entity.Medicationrecord;
import cn.edu.scau.entity.MedicationrecordShow;
import cn.edu.scau.service.MedicationrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MedicationrecordServiceImpl implements MedicationrecordService {
    @Autowired
    MedicationrecordMapper medicationrecordMapper;
    @Override
    public List<MedicationrecordShow> selectAll() {
        return medicationrecordMapper.selectAll();
    }

    @Override
    public List<MedicationrecordShow> findByMIdCId(Integer medicationRecordID, Integer customerID) {
        if(medicationRecordID!=null){
            if(medicationRecordID<1) return null;
        }
        if(customerID!=null){
            if(customerID<1) return null;
        }
        return medicationrecordMapper.findByMIdCId(medicationRecordID,customerID);
    }

    @Override
    public Medicationrecord selectByPrimaryKey(Integer medicationrecordid) {
        return medicationrecordMapper.selectByPrimaryKey(medicationrecordid);
    }

    @Override
    public boolean deleteByPrimaryKey(Integer medicationrecordid) {
        int line = medicationrecordMapper.deleteByPrimaryKey(medicationrecordid);
        return line ==1? true:false;
    }

    @Override
    public boolean insert(Medicationrecord record) {
        int line = medicationrecordMapper.insert(record);
        return line ==1? true:false;
    }

    @Override
    public boolean updateByPrimaryKeySelective(Medicationrecord record) {
        int line = medicationrecordMapper.updateByPrimaryKeySelective(record);
        return line ==1? true:false;
    }
}
